package com.theima.socket.socketdemo7;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
//待解决问题
/**
 * @program: Myset
 * @description: 客户端
 * @author: xuejingjing
 * @create: 2021-06-26 14:33
 **/
public class ClientDemo {
    public static void main(String[] args) throws IOException {

        //1，连哪个计算机，以及端口号
        Socket  socket = new Socket("127.0.0.1",10000);

        //2. 向服务器端传输数据
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("hello".getBytes());


        //3.接受服务器端的数据
        InputStream inputStream = socket.getInputStream();
        int b;
        while( (b = inputStream.read())!=-1){
            System.out.print((char)b);
        }
        //关流
        inputStream.close();
        outputStream.close();
        socket.close();

    }
}
